home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 2
/
Mac Magazin and MacEasy Magazine CD - Issue 02.iso
/
Sharewarebibliothek
/
Applikationen
/
Alpha.5.81 folder
/
Tcl
/
SystemCode
/
think.tcl
< prev
next >
Wrap
Text File
|
1994-06-15
|
8KB
|
329 lines
set THINK "THINK Project Manager"
#set THINK "AEvent Display 1.3"
# Get name Alpha's current name.
foreach p [processes] {
if {[lindex $p 1] == "ALFA"} {
set ALPHA [lindex $p 0]
break
}
}
# The following flags affect the "Run" command.
set runWithDebugger 1
set runWithGo 1
# 'ask ', 'yes ', or 'no '
set runWithUpdate "'yes '"
set runWithSaveDirty "'yes '"
proc thinkNumFiles {} {
global THINK
set str [AEBuild -r $THINK "core" "cnte" "----" {obj{want:type('PDOC'), from:'null'(), form:'indx', seld:1}} "kocl" "type('SFIL')"]
if {[regexp {[0-9]+} $str mtch]} {
return $mtch
} else {
error "Bad numfiles"
}
}
# Get list of files in current project.
proc projectFileList args {
watchCursor
checkRunning ThinkC KAHL thinkName
set num [thinkNumFiles]
set files {}
if {[llength $args]} {
for {set i 1} {$i<=$num} {incr i} {
lappend files [thinkFileName -p $i]
}
} else {
for {set i 1} {$i<=$num} {incr i} {
lappend files [thinkFileName $i]
}
}
return $files
}
#================================================================================
proc think {} {
set name [checkRunning ThinkC KAHL thinkName]
if {![string length $name]} return
switchTo $name
}
proc searchNextFile {} {
thinkFinf
}
proc getProjectFiles args {
menu -n {Project Files} -m -p projFile [lsort [projectFileList -p]]
}
proc projFile {menu name} {
edit [thinkFileName $name]
}
#===========================================================================
# Add fileset.
#===========================================================================
proc createThinkFileset {} {
global fileSets
global currFileSet
set name [prompt "Fileset name? " "Project"]
set fileSets($name) [projectFileList]
addMenuItem -m choose $name
set currFileSet $name
if {[askyesno "Save project fileset?"] == "yes"} {
addUserLine "set \"fileSets($name)\" \{$fileSets($name)\}"
addUserLine "addMenuItem choose \"$name\""
}
makeFilesetMenu
}
#================================================================================
proc checkIncludepath {} {
global includePath
set bad 0
if {![info exists includePath]} {return [setIncludepath]}
foreach p [subVars $includePath] {
if {![file exists $p]} {set bad 1}
}
if ($bad) setIncludepath
}
proc setIncludepath {} {
global includePath HOME
set includePath {}
while {![catch {set path [get_directory]}]} {
lappend includePath $path
}
set fid [open "$HOME:Tcl:SystemCode:definitions.tcl" "a"]
puts $fid "set includePath \"$includePath\""
close $fid
}
proc openHeader {} {
global includePath
checkIncludepath
set path [subVars $includePath]
set fname [getSelect]
if {[string last ".h" $fname]=="-1"} {
set fname ${fname}.h
}
set win [lindex [winNames -f] 0]
if {[string match *:* $win]} {
lappend path [file dirname $win]
}
foreach dir $path {
if {[file exists $dir:$fname]} {
edit $dir:$fname
return
}
}
beep
message "No such header file"
}
#================================================================================
proc sendOpenEvent {filler appname fname} {
AEBuild $appname aevt odoc "----" [concat {[alis(«} [coerce TEXT $fname -x alis] {»)]}]
}
proc compile {} {
sendCompileEvent CMPL "-q"
}
proc checkSyntax {} {
sendCompileEvent SNTX "-q"
}
proc disassemble {} {
global THINK ALPHA
set tname [checkRunning ThinkC KAHL thinkName]
set name [lindex [winNames -f] 0]
switchTo $tname
set res [AEBuild -r $tname KAHL DASM CFLG long(32) "----" [fileObject $name]]
switchTo $ALPHA
new
regexp {“.*”} $res text
insertText [string trim $text {“”}]
}
proc preprocess {} {
global THINK ALPHA
set tname [checkRunning ThinkC KAHL thinkName]
set name [lindex [winNames -f] 0]
switchTo $tname
set res [AEBuild -r $tname KAHL PRCS CFLG long(32) "----" [fileObject $name]]
switchTo $ALPHA
new
regexp {“.*”} $res text
insertText [string trim $text {“”}]
}
proc sendCompileEvent {event arg} {
global THINK ALPHA
set tname [checkRunning ThinkC KAHL thinkName]
set name [lindex [winNames -f] 0]
switchTo $tname
if {[string length $arg]} {
set res [AEBuild $arg $tname KAHL $event "----" [fileObject $name]]
} else {
set res [AEBuild $tname KAHL $event "----" [fileObject $name]]
}
switchTo $ALPHA
return $res
}
proc add {} {
global THINK
set fname [lindex [winNames -f] 0]
AEBuild $THINK core crel "data" [makeAlis $fname] "kocl" "type('SFIL')"
}
proc addAndCompile {} {
add
compile
}
proc precompile {} {
sendCompileEvent PCMP ""
}
proc bringUpToDate {} {
global THINK ALPHA
set name [checkRunning ThinkC KAHL thinkName]
switchTo $name
set res [AEBuild -q $name KAHL CMPL SLCT MAKE "CFLG" "long(2)" "----" {obj{want:type('PDOC'), from:'null'(), form:'indx', seld:1}}]
switchTo $ALPHA
return $res
}
proc make {} {
global THINK ALPHA
set name [checkRunning ThinkC KAHL thinkName]
switchTo $name
set res [AEBuild -q $name KAHL CMPL SLCT MAKE "CFLG" "long(2)" "----" {obj{want:type('PDOC'), from:'null'(), form:'indx', seld:1}}]
}
proc run {} {
global runWithDebugger runWithGo runWithUpdate runWithSaveDirty THINK
set name [checkRunning ThinkC KAHL thinkName]
set dbug [expr {$runWithDebugger ? "bool(«01»)" : "bool(«00»)"}]
set go [expr {$runWithGo ? "bool(«01»)" : "bool(«00»)"}]
switchTo $name
AEBuild $name KAHL "RUN " "DBUG" $dbug "GO " $go "UPDT" $runWithUpdate "savo" $runWithSaveDirty
}
proc debug {} {
global THINK
set fname [lindex [winNames -f] 0]
set row [expr [lindex [posToRowCol [getPos]] 0] - 1]
set res [AEBuild $THINK KAHL DBGF "----" [makeAlis $fname] LNNO "short($row)" ]
}
proc cnt {} {
global THINK
AEBuild -t 6000 -r $THINK core cnte "----" {obj{want:type('PDOC'), from:'null'(), form:'indx', seld:1}} "kocl" "type('sfil')"
}
proc thinkFileName {arg} {
global THINK
set event [join [concat {obj\ \{want:type('prop'),\ from:obj\ \{want:type('SFIL'),\ from:'null'(),\ form:'indx',\ seld:} $arg {\},\ form:'prop',\ seld:type('FSS\ ')\}}] ""]
set blah [AEBuild -r $THINK "core" "getd" "----" $event]
regexp {«.*»} $blah blah
return [specToPathName [string trim $blah {«»}]]
}
#================================================================================
proc handleThinkReply { l } {
global thinkErrors teIndex ALPHA tileHeight winModes terrMenu
set thinkErrors $l
switchTo $ALPHA
set teIndex 0
set errs "Next Previous (-"
foreach err $l {
lappend errs "[file tail [lindex $err 0]]:[lindex $err 2]"
}
menu -m -n $terrMenu -p terrorProc $errs
insertMenu $terrMenu
toThinkError 0
}
proc terrorProc {menu item} {
global thinkErrors
if {$item == "Next"} {return [tnextError]}
if {$item == "Previous"} {return [tpreviousError]}
set ind [string first ":" $item]
set nm [string range $item 0 [expr $ind - 1]]
set ln [string range $item [expr $ind + 1] end]
set i 0
foreach err $thinkErrors {
if {([lindex $err 2] == $ln) && ([file tail [lindex $err 0]] == $nm)} {
return [toThinkError $i]
}
incr i
}
}
proc tpreviousError {} {
global teIndex
incr teIndex -1
if {$teIndex < 0} {set teIndex 0}
toThinkError $teIndex
}
proc tnextError {} {
global teIndex thinkErrors
incr teIndex
set limit [expr [llength $thinkErrors] - 1]
if {$teIndex > $limit} {set teIndex $limit}
toThinkError $teIndex
}
proc toThinkError {ind} {
global thinkErrors tileHeight tileTop tileWidth
set err [lindex $thinkErrors $ind]
set fname [lindex $err 0]
set error [lindex $err 1]
set ln [lindex $err 2]
if {[catch {bringToFront $fname}] } {
edit $fname
}
set pos [rowColToPos $ln 0]
select $pos [nextLineStart $pos]
message $error
}